package org.example.controller;

import org.example.domain.dto.SerialFindCondition;
import org.example.domain.entity.Serial;
import org.example.domain.model.PageData;
import org.example.domain.model.SerialPage;
import org.example.model.Result;
import org.example.service.ISerialService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/serial")
@CrossOrigin("*")
public class SerialController {

    private ISerialService iSerialService;

    public SerialController(ISerialService iSerialService) {
        this.iSerialService = iSerialService;
    }

    @GetMapping("/{page}")
    public Result getPageSerialInfo(@PathVariable Integer page, @RequestParam(defaultValue = "6") Integer limit){
        return Result.buildSuccess(iSerialService.getPageSerialInfo(page,limit));
    }

    @PostMapping("/search")
    public Result finSerialInfo(@RequestBody SerialFindCondition condition){
/*      这里用了一个不匹配的容器来接收,导致报错,我直接给你内联变量了  ---fzl
        SerialPage serialPage = iSerialService.finSerialInfo(condition);
        return Result.buildSuccess(serialPage);*/
        return Result.buildSuccess(iSerialService.finSerialInfo(condition));
    }
}
